<?php

/*
 * EachGo电商网站 新媒体
 * www.eachgo.cn
 */

namespace Home\Model;

/**
 * FundInfoModel
 * 请输入描述
 * @author Moon
 */
use Think\Model;

class FundInfoModel extends Model {
    /*
     * 添加一条资助信息
     */

    public function addFundInfo($obj) {
        $res = $this->add($obj);
        return $res;
    }

    /*
     * 删除一条资助信息
     */

    public function deleteFundInfo($obj) {
        $res = $this->where('ID = "' . $obj['ID'] . '"')->delete();
        return $res;
    }

    /*
     * 更新一条资助信息
     */

    public function updateFundInfo($obj) {
        $res = $this->where('ID = "' . $obj['ID'] . '"')->save($obj);
        return $res;
    }

    /*
     * 查询资助信息by SchoolID
     */

    public function selectFundInfoBySchoolId($obj) {
        $res = $this->where('school_ID = "' . $obj['school_ID'] . '"')->select();
        return $res;
    }

    /*
     * 查询资助信息by 时间段
     */

    public function seletFundInfoByPeriod($obj) {
        $ti = $obj * 30;
        $startTime = date('Y-m-d H:i:s', strtotime('-' . $ti . ' day'));
        $res = $this->where('date between "' . $startTime 
                . '" and "' . date('Y-m-d H:i:s'))->select();
        return $res;
    }

    /*
     * 查找资助信息by Text
     */

    public function selectFundInfoByText($obj) {
        $res = $this->where('text like "%' . $obj . '%"')->select();
        return $res;
    }

}
